<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 面向对象的三大特征之封装

    // 公有的属性和方法 重复创建 占内存

    function Cat(name, color) {
        // {}
        // this -> {}

        //  // 我们要做的操作: 在构造函数执行过程中 将属性和方法绑定到创建的实例化对象上
        this.name = name;
        this.color = color;

        // 公有的属性和方法
        this.species = "Cat";
        this.call = function () {
            console.log("喵喵");
        }
        this.skill = function () {
            console.log("捉老鼠");
        }

        // return this; 默认
    }

    var Tom = new Cat("Tom", "black");
    console.log(Tom, Tom instanceof Cat);

    var Kitty = new Cat("Kitty", "pink");
    console.log(Kitty, Kitty instanceof Cat);

    var LanMao = new Cat("LanMao", "blue");
    console.log(LanMao, LanMao instanceof Cat);
</script>

</html>